package com.king.controller;

import com.king.annotation.SysLog;
import com.king.entity.User;
import com.king.service.UserService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.lang.annotation.Retention;

/**
 * @packageNme com.king.controller
 * @Author: jinguoguang
 * @Date: 2024/5/27 15:14
 * @Version: v1.0.0
 **/
@RestController
@RequestMapping("/user")
@AllArgsConstructor
public class UserController {
    private final UserService userService;


    @RequestMapping("/getUser/{id}")
    @SysLog("根据id获取用户")
    public User getUserById(@PathVariable String id){
        return userService.getUserById(id);
    }

    @SysLog("添加用户")
    @PostMapping("/addUser")
    public User addUser(User user){
        return userService.addUser(user);
    }


    @SysLog("删除用户")
    @PostMapping("/deleteUser/{id}")
    public String deleteUser(@PathVariable String id){
        return userService.deleteUser(id);
    }

    @SysLog("更新用户")
    @PostMapping("/updateUser")
    public User updateUser(User user){
        return userService.updateUser(user);
    }
}
